/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.ins.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.modules.ins.entity.InsTable;
import com.thinkgem.jeesite.modules.ins.entity.InsTemplate;
import com.thinkgem.jeesite.modules.ins.dao.InsTableDao;
import com.thinkgem.jeesite.modules.ins.dao.InsTemplateDao;

/**
 * 模板管理Service
 * @author fanqinglong
 * @version 2017-11-21
 */
@Service
@Transactional(readOnly = true)
public class InsTemplateService extends CrudService<InsTemplateDao, InsTemplate> {
	@Autowired
	private InsTableDao insTableDao;
	
	public InsTemplate get(String id) {
		return super.get(id);
	}
	
	public List<InsTemplate> findList(InsTemplate insTemplate) {
		return super.findList(insTemplate);
	}
	
	public Page<InsTemplate> findPage(Page<InsTemplate> page, InsTemplate insTemplate) {
		return super.findPage(page, insTemplate);
	}
	
	@Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED,readOnly = false, rollbackFor = Exception.class)
	public void save(InsTemplate insTemplate) {
		super.save(insTemplate);
	}
	
	@Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED,readOnly = false, rollbackFor = Exception.class)
	public void delete(InsTemplate insTemplate) {
		super.delete(insTemplate);
	}
	
	public InsTemplate getByName(String name){
		return dao.getByName(name);
	}
	
	public List<InsTable> validDelete(String templateId){
		return insTableDao.getByTemplate(templateId);
	}
}